package Test;

import java.lang.reflect.Field;
import java.util.*;

public class Main {
    public static int max(int n1,int n2){
        return n1>n2?n1:n2;
    }
    public static int max(int n1,int n2,int n3){
        int n = max(n1,n2);
        int t = max(n,n3);
        return t;
    }
    public static int add(int n1,int n2){
        return n1+n2;
    }
    public static double add2(double d1,double d2,double d3){
        return d1+d2+d3;
    }
    public static int[] fun1(int[]arr){
        int length = arr.length;
        int []ret = new int[length];
        int l = 0;int r = length-1;
        for (int i = 0; i < length; i++) {

            if(arr[i]%2 == 0){
                ret[r] = arr[i];
                r--;
            }else {
                ret[l] = arr[i];
                l++;
            }
        }
        return ret;
    }
    public static int binarySearch(int[] arr,int tar){
        int l = 0;
        int r = arr.length-1;
        int mid = (l+r)/2;
        while (l<=r){
            if(arr[mid] == tar){
                return mid;
            }
            if(tar>arr[mid]){
                l = mid;
            }else {
                r = mid;
            }
            mid = (l+r)/2;
        }
        return -1;
    }
    public static int[] bubbleSort(int[] arr){
        for (int i = 0; i < arr.length; i++) {
            boolean flag = false;
            for (int j = i+1; j < arr.length; j++) {
                if(arr[i]>arr[j]){
                    swap(arr,i,j);
                    flag = true;
                }
            }
            if(!flag){
                break;
            }
        }
        return arr;
    }
    private static void swap(int[]arr,int i,int j){
        int t = arr[i];
        arr[i] = arr[j];
        arr[j] = t;
    }
    public static int[] fun(int[] nums,int target){
        int[] ret = new int[2];
        for (int i = 0; i < nums.length; i++) {
            for (int j = i+1; j < nums.length; j++) {
                if(add(nums[i],nums[j]) == target){
                    ret[0] = i;
                    ret[1] = j;
                }
            }
        }
        return ret;
    }
    public static int fun2(int arr[]){
        boolean flag = false;
        for (int i = 0; i < arr.length; i++) {
            flag = false;
            for (int j = i+1; j < arr.length; j++) {
                if(arr[j]==arr[i]){
                    flag = true;
                    break;
                }
            }
            if(!flag){
                return arr[i];
            }
        }
        return -1;
    }
    public static int fun3(int []arr){
        Arrays.sort(arr);
        return arr[arr.length/2];
    }
    public static boolean fun4(int[]arr){
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            if(count>=3){
                return true;
            }
            if(arr[i]%2==0){
                count = 0;
            }else {
                count++;
            }
        }
      return false;
    }


    public static void main(String[] args) {
        //Main main = new Main();
       // System.out.println(main.subsets(new int[]{1}));
//        System.out.println(Main.max(1, 2));
//        System.out.println(Main.max(1, 2, 3));
//        System.out.println(Main.add2(1.1, 1.1, 1.1));
        int []arr = {1,2,3,4,5,6};
        //System.out.println(Arrays.toString(fun1(arr)));
        int []arr22 = {5,4,8,6,1};
        //System.out.println(binarySearch(arr, 2));
        //System.out.println(Arrays.toString(bubbleSort(arr22)));
        int []arr3 = {2,7,11,15};
        int []arr4 = {2,2,1,1,1,2,2};
        System.out.println(fun4(arr4));
        // System.out.println(Arrays.toString(f));

    }

    public static void main3(String[] args) {
        try {
            Class<?> cl = Class.forName("Test.Student");
            Field field = cl.getDeclaredField("name");
            field.setAccessible(true);
            Student student = (Student) cl.newInstance();
            String namevalue = (String) field.get(student);
            System.out.println(namevalue);

        } catch (NoSuchFieldException e) {
            throw new RuntimeException(e);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        }

    }


    public static void main2(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNext()) { // 注意 while 处理多个 case
            String s = in.next();
            Stack<Character> stack = new Stack<>();
            for (char c : s.toCharArray()) {//这种方式可以简明快捷的遍历字符串中的各个字符
                if (!stack.isEmpty() && c == stack.peek()) {
                    stack.pop();
                } else {
                    stack.push(c);
                }
            }
            StringBuilder s2 = new StringBuilder();
            for (char i : stack) {
                s2.append(i);
            }
            System.out.println(s2);
        }
    }

    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int L = in.nextInt();
            int R = in.nextInt();
            int count = 0;
            for (int i = L; i <= R; i++) {
                int number = i;
                while (number != 0) {
                    if (number % 10 == 2) {
                        count++;
                        number /= 10;
                    } else {
                        number /= 10;
                    }
                }
            }
            System.out.print(count);
        }

    }

    public ArrayList<Integer> intersection(ArrayList<Integer> nums1, ArrayList<Integer> nums2) {
        // write code here
        ArrayList<Integer> arrayList = new ArrayList<>();
        ArrayList<Integer> copyNum2 = new ArrayList(nums2);
        for (int i = 0; i < nums1.size(); i++) {

        }
        return arrayList;
    }
}
